Java 隨手記


Posted by Rich on 2022-02-04

encapsulation, abstraction, inheritance, and polymorphism.

  • encapsulation(封裝):
    Each object keeps its state private. Other objects can only access by public methods.

  • abstraction:
    Applying abstraction means that each object should only expose a high-level mechanism for using it.
    This mechanism should hide internal implementation details. It should only reveal operations relevant for the other objects.

  • inheritance(繼承):
    So how do we reuse the common logic and extract the unique logic into a separate class? One way to achieve this is inheritance.

It means that you create a (child) class by deriving from another (parent) class. This way, we form a hierarchy.

The child class reuses all fields and methods of the parent class (common part) and can implement its own (unique part).

  • polymorphism









Related Posts

MTR04_0618

MTR04_0618

學習 Git - 有些檔案想被 Git 忽略

學習 Git - 有些檔案想被 Git 忽略

同步(Sync)& 非同步(Async) 、回呼(Callback)、Promise + then() + catch()、async + await + try + catch

同步(Sync)& 非同步(Async) 、回呼(Callback)、Promise + then() + catch()、async + await + try + catch


Comments